package finely;

import java.util.Scanner;

/**
 * All rights Reserved, Designed By www.tusdao.com
 *
 * @version V1.0
 * @Title: TwoNum
 * @Package myTest
 * @Description: TODO(一句话描述类是干嘛的)
 * @author: tusxxw
 * @date: 2020/12/19
 * @Copyright: 2020 www.tbs.com Inc. All rights reserved.
 * <p>
 * 注意：本内容仅限于TBS项目组内部传阅，禁止外泄以及用于其他的商业目的
 */
public class TwoNum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int sum = 0;
        int flag = 0;
        int sw = 0;
        int temp = 0;
        for (int i = 0; i < num; i++) {
            temp = sc.nextInt();
            if (temp == 2) {
                sum++;
                sw=1;
            }else if (temp !=2 && sw ==1 &&flag == 0) {
                System.out.print(sum);
                sum = 0;
                flag = 1;
            }else if (temp !=2 && sw ==1 && flag != 0 ) {
                System.out.print(" " + sum);
                sum = 0;
            }
        }
        if(temp==2){
            System.out.print(" " + sum);
        }

    }
}
